//
//  CollectionExperienceCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/9/11.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "CollectionExperienceCell.h"

@interface CollectionExperienceCell ()
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *dayNumberLabel;
@property (nonatomic, strong) UILabel *dayLabel;
@property (nonatomic, strong) UILabel *hourNumberLabel;
@property (nonatomic, strong) UILabel *hourLabel;
@property (nonatomic, strong) UILabel *minuteNumberLabel;
@property (nonatomic, strong) UILabel *minuteLabel;
@property (nonatomic, strong) UILabel *secondNumberLabel;
@property (nonatomic, strong) UILabel *secondLabel;

@property (nonatomic, strong) UILabel *applyLabel;//限量

@property (nonatomic, strong) UILabel *nunmberLabel;
@property (nonatomic, strong) UIImageView *collectImg;
@end
@implementation CollectionExperienceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
        _imgView = [UIImageView new];
        _imgView.backgroundColor = ColorCyan;
        [self addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(10);
            make.left.equalTo(self).offset(10);
            make.width.equalTo(@125);
            make.height.equalTo(@125);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影秋季梦想儿童摄影秋季梦想秋季梦想";
        _titleLabel.textColor = ColorFrom16(0x323232);
        _titleLabel.font = PFRFONT(14);
        _titleLabel.numberOfLines = 2;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(8);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.right.equalTo(self).offset(-10);
            make.height.height.equalTo(@40);
        }];
        
        _dayNumberLabel = [UILabel new];
        _dayNumberLabel.text = @"3";
        _dayNumberLabel.textColor = ColorFrom16(0xffffff);
        _dayNumberLabel.layer.backgroundColor = ColorFrom16(0xff8ca2).CGColor;
        _dayNumberLabel.layer.cornerRadius = 4;
        _dayNumberLabel.font = PFMFONT(12);
        _dayNumberLabel.textAlignment = 1;
        [self addSubview:_dayNumberLabel];
        [_dayNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.width.greaterThanOrEqualTo(@23);
            make.height.equalTo(@19);
        }];
        
        _dayLabel = [UILabel new];
        _dayLabel.text = @"天";
        _dayLabel.textColor = ColorFrom16(0xff8ca2);
        _dayLabel.font = PFMFONT(12);
        [self addSubview:_dayLabel];
        [_dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_dayNumberLabel.mas_right).offset(2);
            make.width.equalTo(@13);
            make.height.equalTo(@17);
        }];
        
        _hourNumberLabel = [UILabel new];
        _hourNumberLabel.text = @"13";
        _hourNumberLabel.textColor = ColorFrom16(0xffffff);
        _hourNumberLabel.layer.backgroundColor = ColorFrom16(0xff8ca2).CGColor;
        _hourNumberLabel.layer.cornerRadius = 4;
        _hourNumberLabel.font = PFMFONT(12);
        _hourNumberLabel.textAlignment = 1;
        [self addSubview:_hourNumberLabel];
        [_hourNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_dayLabel.mas_right).offset(2);
            make.width.equalTo(@23);
            make.height.equalTo(@19);
        }];
        
        _hourLabel = [UILabel new];
        _hourLabel.text = @"小时";
        _hourLabel.textColor = ColorFrom16(0xff8ca2);
        _hourLabel.font = PFMFONT(12);
        [self addSubview:_hourLabel];
        [_hourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_hourNumberLabel.mas_right).offset(2);
            make.width.equalTo(@26);
            make.height.equalTo(@17);
        }];
        
        _minuteNumberLabel = [UILabel new];
        _minuteNumberLabel.text = @"03";
        _minuteNumberLabel.textColor = ColorFrom16(0xffffff);
        _minuteNumberLabel.layer.backgroundColor = ColorFrom16(0xff8ca2).CGColor;
        _minuteNumberLabel.layer.cornerRadius = 4;
        _minuteNumberLabel.font = PFMFONT(12);
        _minuteNumberLabel.textAlignment = 1;
        [self addSubview:_minuteNumberLabel];
        [_minuteNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_hourLabel.mas_right).offset(2);
            make.width.equalTo(@23);
            make.height.equalTo(@19);
        }];
        
        _minuteLabel = [UILabel new];
        _minuteLabel.text = @"分";
        _minuteLabel.textColor = ColorFrom16(0xff8ca2);
        _minuteLabel.font = PFMFONT(12);
        [self addSubview:_minuteLabel];
        [_minuteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_minuteNumberLabel.mas_right).offset(2);
            make.width.equalTo(@13);
            make.height.equalTo(@17);
        }];
        
        _secondNumberLabel = [UILabel new];
        _secondNumberLabel.text = @"53";
        _secondNumberLabel.textColor = ColorFrom16(0xffffff);
        _secondNumberLabel.layer.backgroundColor = ColorFrom16(0xff8ca2).CGColor;
        _secondNumberLabel.layer.cornerRadius = 4;
        _secondNumberLabel.font = PFMFONT(12);
        _secondNumberLabel.textAlignment = 1;
        [self addSubview:_secondNumberLabel];
        [_secondNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_minuteLabel.mas_right);
            make.width.equalTo(@23);
            make.height.equalTo(@19);
        }];
        
        _secondLabel = [UILabel new];
        _secondLabel.text = @"秒";
        _secondLabel.textColor = ColorFrom16(0xff8ca2);
        _secondLabel.font = PFMFONT(12);
        [self addSubview:_secondLabel];
        [_secondLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(6);
            make.left.equalTo(_secondNumberLabel.mas_right).offset(2);
            make.width.equalTo(@26);
            make.height.equalTo(@17);
        }];
        
        _applyLabel = [UILabel new];
        _applyLabel.text = @"限量 20 ／申请 200人";
        _applyLabel.textColor = ColorFrom16(0x7f7e7d);
        _applyLabel.font = PFRFONT(11);
        [self addSubview:_applyLabel];
        [_applyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_dayLabel.mas_bottom).offset(3);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.width.greaterThanOrEqualTo(@145);
            make.height.equalTo(@16);
        }];
        NSMutableAttributedString *aString = [[NSMutableAttributedString alloc] initWithString:_applyLabel.text];
        NSRange range = [[aString string] rangeOfString:@"20"];
        [aString addAttribute:NSForegroundColorAttributeName value:ColorFrom16(0xFF8CA2) range:range];
        
        NSRange range1 = [[aString string] rangeOfString:@"200"];
        [aString addAttribute:NSForegroundColorAttributeName value:ColorFrom16(0xFF8CA2) range:range1];
        _applyLabel.attributedText = aString;
        
        
        
        _goToApply = [UIButton buttonWithType:UIButtonTypeCustom];
        [_goToApply setTitle:@"立即申请" forState:0];
        [_goToApply setTitleColor:ColorFrom16(0xffffff) forState:0];
        _goToApply.titleLabel.font = PFRFONT(14);
        _goToApply.layer.backgroundColor = ColorFrom16(0xff5b7a).CGColor;
        _goToApply.layer.cornerRadius = 4;
        [self addSubview:_goToApply];
        [_goToApply mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-10);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.width.equalTo(@74);
            make.height.equalTo(@30);
        }];
        
        
        _nunmberLabel = [UILabel new];
        _nunmberLabel.text = @"20";
        _nunmberLabel.textColor = ColorFrom16(0x999999);
        _nunmberLabel.font = PFRFONT(14);
        [self addSubview:_nunmberLabel];
        [_nunmberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-10);
            make.right.equalTo(self).offset(-10);
            make.width.greaterThanOrEqualTo(@19);
            make.height.equalTo(@20);
        }];
        
        _collectImg = [UIImageView new];
        _collectImg.backgroundColor = ColorGreen;
        [self addSubview:_collectImg];
        [_collectImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-15.1);
            make.right.equalTo(_nunmberLabel.mas_left).offset(-6);
            make.width.equalTo(@10.7);
            make.height.equalTo(@9.3);
        }];
        
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
